<template>
  <NavBar />

  <!-- 模拟试卷-->
  <van-cell v-for="item in paperList" :title="item.paperName" is-link @click="toQuestionHandle(item.id)" />

</template>

<script>
import NavBar from "@/components/layout/nav-bar";
import { onBeforeMount, reactive,  toRefs } from "vue"
import { useRouter } from "vue-router"
import http from "@/utils/http";
import { showFailToast } from "vant"
export default {
  name: "simulation",
  components: {
    NavBar
  },

  setup() {
    const router = useRouter();
    const state = reactive({
      paperList: []
    })

    onBeforeMount(()=>{
      http.get("/exam/paper/list",{ params:{ paperType: 1, subjectId: localStorage.subjectId }}).then(({ data: res})=>{
        if (res.code !==0){
          return showFailToast(res.msg)
        }
        state.paperList = res.data
      })
    })

    const toQuestionHandle = ((id)=>{
      router.push({ name: 'question', params: { id: id, examType: "SIMULATION" } })
    })

    return {
      ...toRefs(state),
      toQuestionHandle
    };
  },
}
</script>

<style scoped>

</style>
